import { Component } from '@angular/core';
import { Passengerreport } from './passengerreport';

import { OnInit } from '@angular/core';
import { Router } from '@angular/router';

import { PassengerreportService } from './passengerreport.service';

@Component({
  selector: 'my-passengerreports',
  templateUrl: './passengerreport.component.html'
})

export class PassengerreportComponent implements OnInit {
  ngOnInit() {
  }

  passengerreports: Passengerreport[];

  start_time = new Date().toDateString();
  end_time = new Date().toDateString();

  datePickerConfig = {
    "firstDayOfWeek": "su",
    "calendarsAmount": 1,
    "format": "YYYY-MM-DD",
    "monthFormat": "YYYY-MM-DD",
    "closeOnSelect": true,
    "closeOnSelectDelay": 100,
    "weekdayNames": {
      "su": "日",
      "mo": "一",
      "tu": "二",
      "we": "三",
      "th": "四",
      "fr": "五",
      "sa": "六"
    },
    "disableKeypress": true
  };

  constructor(
    private passengerreportService: PassengerreportService) {
  }

  getPassengerreports() {
    this.passengerreportService.searchPassengerreports(this.start_time, this.end_time).then(passengerreports => this.passengerreports = passengerreports);
  }

  search() {
    this.getPassengerreports();
  }
}
